﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="/resource/css/table.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
</head>
<style>
    .layui-upload-img {
        width: 200px;
        height: 200px;
    }

    .submitBtn {
        margin-top: 40px;
        margin-left: 49%;
    }
</style>
<body style="background-color: #e6ecf5;min-width: 1100px">
<div class="book_con01">
    <h1 class="book_h01">网站参数设置</h1>
    <div id="form_demo layui-form">
        <input hidden id="id" th:value="${wbeParameter.id}"/>
        <table class="book_table" border="1" cellpadding="10">
            <tr>
                <td class="table_td"><p>网站名称</p><span></span></td>
                <td>
                    <input type="text" id="name" th:value="${wbeParameter.name}" class="book_input03"/>
                </td>
                <td class="table_td"><p>域名</p><span></span></td>
                <td>
                    <input type="text" id="yu" th:value="${wbeParameter.yu}" class="book_input03"/>
                </td>
                <td class="table_td"><p>版权</p><span></span></td>
                <td>
                    <input type="text" id="copyright" th:value="${wbeParameter.copyright}"
                           class="book_input03"/>
                </td>
                <td class="table_td"><p>版本年限</p><span></span></td>
                <td>
                    <input type="text" id="year" th:value="${wbeParameter.year}"
                           class="book_input03"/>
                </td>
                <td class="table_td"><p>版本号</p><span></span></td>
                <td>
                    <input type="text" id="code" th:value="${wbeParameter.code}"
                           class="book_input03"/>
                </td>
            </tr>
            <tr>
                <td class="table_td"><p>预警阈值</p><span></span></td>
                <td>
                    <input type="text" id="threshold" th:value="${wbeParameter.threshold}" class="book_input03"/>
                </td>
                <td class="table_td"><p>网站logo</p><span></span></td>
                <td><input type="text" class="book_input03" name="logo" id="logo"
                           th:value="${wbeParameter.logo}"
                           minlength="2"
                           required/></td>
                <td class="table_td"><p>热销推荐数</p><span></span></td>
                <td>
                    <input type="number" id="hotNumber" class="book_input03" th:value="${wbeParameter.hotNumber}"
                           min="1"/>
                </td>
                <td class="table_td"><p>新品推荐数</p><span></span></td>
                <td>
                    <input type="number" id="newNumber" class="book_input03" th:value="${wbeParameter.newNumber}"
                           min="1"/>
                </td>
                <td class="table_td"><p>客服电话</p><span></span></td>
                <td>
                    <input type="text" id="iphone" th:value="${wbeParameter.iphone}" class="book_input03"/>
                </td>

            </tr>
            <tr>
                <td class="table_td table_td1"><p>首页底部banner</p><span></span></td>
                <td colspan="10" class="sex">
                    <div class="layui-upload">
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" th:src="${wbeParameter.bottomImg}" id="uploadBtn">
                            <p id="demoText"></p>
                            <input name="bottomImg" th:value="${wbeParameter.bottomImg}" hidden id="bottomImg"/>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="table_td table_td1"><p>登录/注册背景图</p><span></span></td>
                <td colspan="10" class="sex">
                    <div class="layui-upload">
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" th:src="${wbeParameter.backgroundImg}" id="uploadBtn1">
                            <p id="demoText1"></p>
                            <input name="backgroundImg" th:value="${wbeParameter.backgroundImg}" hidden
                                   id="backgroundImg"/>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="table_td table_td1"><p>关于我们</p><span></span></td>
                <td colspan="10" style="text-align: left">
                    <textarea id="aboutWe" th:utext="${wbeParameter.aboutWe}"
                              class="layui-textarea fly-editor"></textarea>
                </td>
            </tr>
        </table>
        <button lay-submit="" lay-filter="Submit" class="submitBtn">保存修改</button>
    </div>
</div>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript">


    layui.use(['layer', 'layedit', 'form', 'upload',], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            upload = layui.upload,
            layedit = layui.layedit,
            form = layui.form;
        upload.render({
            elem: '#uploadBtn'
            , url: '/upload.do'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#uploadBtn').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                console.log(res)
                //如果上传失败
                if (!res.status) {
                    return layer.msg('上传失败');
                }
                $("#bottomImg").val(res.obje);
                return layer.msg('上传成功');
            }
            , error: function () {
                return layer.msg('上传失败');
            }
        });
        upload.render({
            elem: '#uploadBtn1'
            , url: '/upload.do'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#uploadBtn1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                console.log(res)
                //如果上传失败
                if (!res.status) {
                    return layer.msg('上传失败');
                }
                $("#backgroundImg").val(res.obje);
                return layer.msg('上传成功');
            }
            , error: function () {
                return layer.msg('上传失败');
            }
        });
        form.on('submit(Submit)', function (data) {
            var id = $("#id").val();
            var logo = $("#logo").val();
            var hotNumber = $("#hotNumber").val();
            var newNumber = $("#newNumber").val();
            var recommendOne = $("#recommendOne").val();
            var recommendTwo = $("#recommendTwo").val();
            var recommendThree = $("#recommendThree").val();
            var bottomImg = $("#bottomImg").val();
            var threshold = $("#threshold").val();
            var backgroundImg = $("#backgroundImg").val();
            var iphone = $("#iphone").val();
            var name = $("#name").val();
            var yu = $("#yu").val();
            var code = $("#code").val();
            var copyright = $("#copyright").val();
            var year = $("#year").val();
            var aboutWe = layedit.getContent(index)
            $.ajax({
                url: '/wbeSet/wbeParameter.do',
                type: 'put',
                data: {
                    "id": id,
                    "logo": logo,
                    "hotNumber": hotNumber,
                    "newNumber": newNumber,
                    "recommendOne": recommendOne,
                    "recommendTwo": recommendTwo,
                    "threshold": threshold,
                    "recommendThree": recommendThree,
                    "bottomImg": bottomImg,
                    "iphone": iphone,
                    "backgroundImg": backgroundImg,
                    "code": code,
                    "name": name,
                    "yu": yu,
                    "copyright": copyright,
                    "year": year,
                    "aboutWe": aboutWe
                },
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (result.status) {
                        layer.msg("修改成功!")
                    } else {
                        alert("修改失败!")
                    }
                }

            });
        });
        layedit.set({
            //暴露layupload参数设置接口 --详细查看layupload参数说明
            uploadImage: {
                url: '/layeditUpload.do',
                accept: 'image',
                acceptMime: 'image/*',
                exts: 'jpg|png|gif|bmp|jpeg',
                size: '10240'
            }
            , uploadVideo: {
                url: '/layeditUpload.do',
                accept: 'video',
                acceptMime: 'video/*',
                exts: 'mp4|flv|avi|rm|rmvb',
                size: '20480'
            }
            //右键删除图片/视频时的回调参数，post到后台删除服务器文件等操作，
            //传递参数：
            //图片： imgpath --图片路径
            //视频： filepath --视频路径 imgpath --封面路径
            , calldel: {
                url: '/Attachment/DeleteFile'
            }
            //开发者模式 --默认为false
            , devmode: true
            //插入代码设置
            , codeConfig: {
                hide: true,  //是否显示编码语言选择框
                default: 'javascript' //hide为true时的默认语言格式
            }
            , tool: [
                'code', 'strong', 'italic', 'underline', 'del', 'addhr', '|', 'fontFomatt', 'colorpicker', 'face'
                , '|', 'left', 'center', 'right', '|', 'link', 'unlink', 'images', 'image_alt', 'video', 'anchors'
                , '|', 'table', 'fullScreen']

        });
        var index = layedit.build('aboutWe', {
            height: 400 //设置编辑器高度
        });
    });

</script>
</body>
</html>
